package gwtmodule1.client.gui.admin;

import gwtmodule1.client.gui.utils.DekoTable;
import gwtmodule1.client.gui.utils.FormTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.HSpacer;
import gwtmodule1.client.gui.utils.Title;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageEditCategory extends VerticalPanel implements FrameClient {

	private class PeopleTable extends DekoTable {

		public PeopleTable() {
			addTitle("Login");
			addTitle("First Name");
			addTitle("Last Name");
			addTitle("");

			ListBox users = new ListBox();
			users.addItem("god (Bruce Almighty)");
			users.addItem("coolguy (Fritz Friese)");
			users.setSelectedIndex(0);

			AddRow r = addRow();
			r.add(users).setColspan(3).setHAlign(r.RIGHT);
			r.add(new Button("add"));
		}
		
		public void addPerson(int id, String login, String fName, String lName) {
			AddRow r = addRow(1);
			r.add(login);
			r.add(fName);
			r.add(lName);
			r.add(new Button("remove"));
		}

	}
	
	private Widget createManagerList() {
		PeopleTable table = new PeopleTable();
		table.addPerson(1, "leopold", "Leopold", "Lion");
		table.addPerson(2, "carl", "Carl", "Krause");
		return table;
	}
	
	private Widget createStaffList() {
		PeopleTable table = new PeopleTable();
		table.addPerson(1, "fritz", "Fritz", "Fleissig");
		table.addPerson(2, "klara", "Klara", "Klosbruehe");
		return table;
	}

	private Widget createForm() {
		FormTable table = new FormTable();
		table.addInput("Name", new TextBox());
		table.addButton("Save", null);
		return table;
	}

	private Title title = new Title("Edit/Create Category");

	public PageEditCategory() {
		super();
		add(title);
		add(createForm());
		add(new HSpacer());
		add(new HTML("<b>Manager</b>"));
		//add(new HSpacer("4px"));
		add(createManagerList());
		add(new HSpacer());
		add(new HTML("<b>Staff</b>"));
		//add(new HSpacer("4px"));
		add(createStaffList());
	}

	public void onShow(Object param) {
		int id = ((Integer) param).intValue();
		title.setTitle((id == 0) ? "Create Category" : "Edit Category");
	}

}
